﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using WebChatApi.Common.Interface;

/// <summary>
/// The Common namespace.
/// </summary>
namespace WebChatApi.Common
{
    /// <summary>
    /// Class for binary.
    /// Example for Xml serialization:
    /// <code>
    /// <![CDATA[
    /// <?xml version="1.0" encoding="utf-16"?>
    /// <Binary xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebChatApi.Common">
    /// <Bytes>iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAIAAADwlwNsAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA8ElEQVQYlV2QS44bQQxDRZXchq86d8kpcj3vDLinLJHMogEvsufnkfj587dHNqe7KjN8nmfIj8dDn34+n3nc71VFMiKqqqoyMyIkRcT9fk8AkkivtapqrfW/oqmhAdxut8y0DaCqAGTmcRxFUlIdt7XW13olpQygJFXVKqyV0lzW3h/bKXd3SQKW7Zkhm/3pbkkk9emZSVMASF6k3/qLqaoyQkibugbbJkmyu2dmrVUA4IgIAEBEBMke7r09Y7sCkpQZx3FcpN9FtvfepaGTVYvk7+95nufe25Tt7n69XilJmsy0uffee8/MdSCA9/v9D8pF2X+82l5TAAAAAElFTkSuQmCC</Bytes>
    /// <Extension i:nil="true" />
    /// <FileName i:nil="true" />
    /// <Key>00000000-0000-0000-0000-000000000000</Key>
    /// </Binary>
    /// ]]>
    /// </code>
    /// Example for Json serialization:
    /// <code>
    /// <![CDATA[
    /// [{
    /// "Key":"00000000-0000-0000-0000-000000000000",
    /// "FileName":null,
    /// "Extension":null,
    /// "Bytes":"iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAIAAADwlwNsAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA8ElEQVQYlV2QS44bQQxDRZXchq86d8kpcj3vDLinLJHMogEvsufnkfj587dHNqe7KjN8nmfIj8dDn34+n3nc71VFMiKqqqoyMyIkRcT9fk8AkkivtapqrfW/oqmhAdxut8y0DaCqAGTmcRxFUlIdt7XW13olpQygJFXVKqyV0lzW3h/bKXd3SQKW7Zkhm/3pbkkk9emZSVMASF6k3/qLqaoyQkibugbbJkmyu2dmrVUA4IgIAEBEBMke7r09Y7sCkpQZx3FcpN9FtvfepaGTVYvk7+95nufe25Tt7n69XilJmsy0uffee8/MdSCA9/v9D8pF2X+82l5TAAAAAElFTkSuQmCC"
    /// }
    /// ]]>
    /// </code>
    /// </summary>
    [DataContract]
    
    public class Binary : IIdentifiable
    {
        #region Properties

        /// <summary>
        /// Gets or sets the key.
        /// </summary>
        /// <value>The key.</value>
        [DataMember]
        public Guid Key
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the name of the file.
        /// </summary>
        /// <value>The name of the file.</value>
        [DataMember]
        public string FileName { get; set; }

        /// <summary>
        /// Gets or sets the exetension.
        /// </summary>
        /// <value>The exetension.</value>
        [DataMember]
        public string Extension { get; set; }


        /// <summary>
        /// Gets or sets the bytes.
        /// In serialization, byte content would be serialized to Base64 string.
        /// </summary>
        /// <value>The bytes.</value>
        [DataMember]
        public Byte[] Bytes { get; set; }

        /// <summary>
        /// Gets the full name.
        /// </summary>
        /// <value>The full name.</value>
        public string FullName
        {
            get
            {
                return this.CombineExtension(this.FileName, this.Extension);
            }
        }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="Binary" /> class.
        /// </summary>
        public Binary()
        {
        }

        #endregion

        #region Convertion

        #endregion

    }
}
